//
//  ReportCardDataItemView.m
//  jzyParents
//
//  Created by 任辰东 on 2022/8/22.
//

#import "ReportCardDataItemView.h"

@interface ReportCardDataItemView ()

@property (nonatomic, strong) UILabel *label1;
@property (nonatomic, strong) UILabel *label2;
@property (nonatomic, strong) UILabel *label3;
@property (nonatomic, strong) UILabel *label4;
@property (nonatomic, strong) UILabel *label5;
@end

@implementation ReportCardDataItemView

-(void)configViewWithModel:(Chengji_duibi_listItem *)model
{
    if (model.type.integerValue == 1) {
        self.label1.font = UIFontSize(13);
        self.label2.font = UIFontSize(13);
        self.label3.font = UIFontSize(13);
        self.label4.font = UIFontSize(13);
        self.label5.font = UIFontSize(13);
    }else{
        self.label1.font = UIFontSize(12);
        self.label2.font = UIFontSize(12);
        self.label3.font = UIFontSize(12);
        self.label4.font = UIFontSize(12);
        self.label5.font = UIFontSize(12);
    }
    
    self.label1.text = model.kemu_name;
    self.label2.text = model.score;
    if (model.type.integerValue == 1) {
        self.label3.text = model.average_score;
    } else {
        self.label3.text = [NSString stringWithFormat:@"%.1f",model.average_score.floatValue];
    }
   
    self.label4.text = model.top_score;
    self.label5.text = model.gap_score;
}

-(void)setupViews
{
    [self addSubview:self.label1];
    [self addSubview:self.label2];
    [self addSubview:self.label3];
    [self addSubview:self.label4];
    [self addSubview:self.label5];
}

-(void)setupLayout
{
    CGFloat width = (kScreenWidth - 15) /5.0;
    [self.label1 mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self).offset(15);
        make.width.mas_equalTo(width);
    }];
    
    [self.label2 mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.label1.mas_right).offset(0);
        make.top.equalTo(self).offset(15);
        make.width.mas_equalTo(width);
    }];
    
    [self.label3 mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.label2.mas_right).offset(0);
        make.top.equalTo(self).offset(15);
        make.width.mas_equalTo(width);
    }];
    
    [self.label4 mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.label3.mas_right).offset(0);
        make.top.equalTo(self).offset(15);
        make.width.mas_equalTo(width);
    }];
    
    [self.label5 mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.label4.mas_right).offset(0);
        make.top.equalTo(self).offset(15);
        make.width.mas_equalTo(width);
        make.bottom.equalTo(self);
    }];
}

#pragma mark -- lazyload

-(UILabel *)label1
{
    if (!_label1) {
        _label1 = [UILabel new];
        _label1.textColor = UIColorFromHex(0x000000);
        _label1.font = UIFontSize(13);
        _label1.textAlignment = NSTextAlignmentLeft;
    }
    return _label1;
}

-(UILabel *)label2
{
    if (!_label2) {
        _label2 = [UILabel new];
        _label2.textColor = UIColorFromHex(0x000000);
        _label2.font = UIFontSize(13);
        _label2.textAlignment = NSTextAlignmentCenter;
    }
    return _label2;
}

-(UILabel *)label3
{
    if (!_label3) {
        _label3 = [UILabel new];
        _label3.textColor = UIColorFromHex(0x000000);
        _label3.font = UIFontSize(13);
        _label3.textAlignment = NSTextAlignmentCenter;
    }
    return _label3;
}


-(UILabel *)label4
{
    if (!_label4) {
        _label4 = [UILabel new];
        _label4.textColor = UIColorFromHex(0x000000);
        _label4.font = UIFontSize(13);
        _label4.textAlignment = NSTextAlignmentCenter;
    }
    return _label4;
}

-(UILabel *)label5
{
    if (!_label5) {
        _label5 = [UILabel new];
        _label5.textColor = UIColorFromHex(0x000000);
        _label5.font = UIFontSize(13);
        _label5.textAlignment = NSTextAlignmentCenter;
    }
    return _label5;
}

@end
